package hlhj.fhp.checkpoint.module

import android.content.Context
import com.example.mymvp.mvp.BaseModule
import com.lzy.okgo.model.Response
import hlhj.fhp.checkpoint.http.Apis
import hlhj.fhp.checkpoint.http.CustomAction
import hlhj.fhp.checkpoint.http.LoadingAction
import hlhj.fhp.checkpoint.javaBean.ShareBean

/**
 * Created by Never Fear   on 2018\11\13 0013.
Never More....
 */
class ShareModule :BaseModule {
    var listener:ShareListener?=null

    fun getShare(type:Int,page:Int,level:Int,c:Context){
        Apis.getShare(type, page,level)
                ?.let {
                    it.doOnSubscribe(LoadingAction(c))
                            .subscribe(object :CustomAction<Response<ShareBean>>(c){
                                override fun httpSuccess(t: Response<ShareBean>) {
                                    listener?.getShareResp(t.body())
                                }
                            })
                }
    }

    interface ShareListener{

        fun getShareResp(shareBean: ShareBean)
    }
}